package com.ttwm.dao;

import com.ttwm.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserDao {
    //注册
    @Insert("insert into t_user(username,password,phone,address,signature,chooseImage) values (#{username},#{password},#{phone},#{address},#{signature},#{chooseImage})")
    int insertUser(User user);

    //登录
    @Select("select * from t_user where username=#{username} and password=#{password}")
    User loginUser(User user);

    @Select("select * from t_user where userId=#{userId}")
    User oneUser(User user);

    @Select("select * from t_user")
    List<User> allUser();

    @Select("select * from t_user where phone=#{phone}")
    User phoneUser(User user);

    // 修改头像，目前来说没啥用
    @Update("update t_user set username=#{username},password=#{password},phone=#{phone},address=#{address},signature=#{signature},chooseImage=#{chooseImage},remark=#{remark} where userId=#{userId}")
    int updateUser(User user);

    @Delete("delete from t_user where userId=#{userId}")
    int deleteUser(User user);


}
